VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsMarcas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Dim vSQL As String

Public pNumError As Long
Public pDesError As String
Public pCanReg As Long
Public pRS As ADODB.Recordset
Public pIdDevuelto As Long

Private vIdMarca As Long

Public Property Let IdMarca(ByVal VData As Long)
    vIdMarca = VData
End Property
Public Property Get IdMarca() As Long
    IdMarca = vIdMarca
End Property

Private Sub AsignarValores(Optional ByVal rs As ADODB.Recordset, Optional pNoAsigRs As Boolean)
    If Not pNoAsigRs Then
        Set Me.pRS = rs
    End If
    Me.pCanReg = objCnxAeros.pCanReg
    Me.pDesError = objCnxAeros.pDesError
    Me.pIdDevuelto = objCnxAeros.pUltIdenOtor
    Me.pNumError = objCnxAeros.pNumError
End Sub

Public Function sel_Marcas(Optional ByVal nombreMarca)
Dim rs As New ADODB.Recordset
Dim strSQL As String

    If Not IsMissing(nombreMarca) Then
        strSQL = "SELECT id_marca,marca From marcas WHERE fecha_baja is null AND marca like '%" & nombreMarca & "%' ORDER BY marca"
    Else
        strSQL = "SELECT id_marca,marca From marcas WHERE fecha_baja is null ORDER BY marca"
    End If
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Function

Public Function ActualizarMarca_by_ID(ByVal id_marca As Long, marca As String) As Boolean
Dim strSQL As String

strSQL = " UPDATE marcas SET marca='" & marca & _
                                        "' WHERE marcas.id_marca =" & id_marca
    
                                        
    If objCnxAeros.EjecutarComando(strSQL) Then
        ActualizarMarca_by_ID = True
    Else
        ActualizarMarca_by_ID = False
    End If

End Function

Public Function BorrarMarca_by_ID(ByVal ID As Long)
Dim strSQL As String

    strSQL = " UPDATE marcas SET fecha_baja ='" & Date & "'" & _
             " WHERE marcas.id_marca =" & ID

    If objCnxAeros.EjecutarComando(strSQL) Then
        BorrarMarca_by_ID = True
    Else
        BorrarMarca_by_ID = False
    End If

End Function

Public Function grabarMarca(ByVal marca As String)

Dim strSQL As String
    
    strSQL = " INSERT INTO marcas (marca) values ('" & marca & "')"
                                    
    If objCnxAeros.EjecutarComando(strSQL) Then
        grabarMarca = True
    Else
        grabarMarca = False
    End If

End Function

Public Function cargarMarca_by_ID(ByVal ID As Long)
Dim rs As New ADODB.Recordset
Dim strSQL As String
   
   strSQL = " SELECT id_marca, marca, " & _
            " fecha_baja FROM marcas WHERE id_marca = " & ID
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    
    AsignarValores rs

End Function








